package com.trial.eyefollowupapp

import retrofit2.Response
import retrofit2.http.*

interface ApiService {
    // 用户登录 - 修改路径为/api/login
    @FormUrlEncoded
    @POST("/api/login")
    suspend fun login(
        @Field("username") username: String,
        @Field("password") password: String
    ): Response<LoginResponse>

    // 获取随访记录列表 - 修改返回类型
    @GET("/debug_records")
    suspend fun getRecords(): Response<RecordsResponse>

    // 获取记录详情
    @GET("/record_json/{record_id}")
    suspend fun getRecordDetail(@Path("record_id") recordId: Int): Response<RecordDetailResponse>
}

// 数据模型
// 添加新的数据类来匹配服务器返回的格式
data class RecordsResponse(
    val user: String,
    val records_count: Int,
    val records: List<RecordResponse>
)

data class RecordResponse(
    val id: Int,
    val doctor_name: String,
    val username: String,
    val date: String
    // 其他必要字段
)

data class RecordDetailResponse(
    val id: Int,
    val doctor: String,
    val patient_name: String,
    val date: String,
    val left_eye_url: String?,
    val right_eye_url: String?,
    val diagnoses: List<Diagnosis>,
    val advice_deepseek: String,
    val advice_huatuo: String
)

data class Diagnosis(
    val name: String,
    val risk_level: String
)

// 删除原有的Advice类定义
// data class Advice(
//     val source: String,
//     val content: String
// )

// 添加登录响应模型
data class LoginResponse(
    val message: String
)